<template>
	<template>
		<view class="container">
			<view v-if="list.length>0">
				<uni-list v-for="item in list">
					<uni-list-item :thumb="path+item.avatarBytes" thumb-size="lg" :title="item.name"
						:note="item.status==1?'驳回原因:'+item.remark:''"
						:to="'/pages/detail/index?item='+JSON.stringify(item)">
						<template v-slot:body>
							<view class="item">
								<view class="name">
									{{item.name}}
								</view>
								<view class="group">
									<text>
										{{item.groupName}}
									</text>

									<text>{{item.type==1?'业主':item.type==2?'访客':'黑名单'}}</text>
								</view>
								<view class="remark">
									{{item.status==1?'驳回原因:'+item.remark:''}}
								</view>
							</view>

						</template>
						<template v-slot:footer>
							<uni-tag :text="item.status==0?'待审核':item.status==1?'已驳回':'已通过'"
								:type="item.status==0?'primary':item.status==1?'error':'success'" />

						</template>
					</uni-list-item>

				</uni-list>
			</view>
			<view v-else>
				<no-data />
			</view>


		</view>
	</template>

</template>

<script>
	import {
		getGroupList,
		getGroupName
	} from "../../utils/common"
	import {
		request,
		baseURL
	} from "@/api/request.js"
	import noData from "../../component/no-data.vue"
	export default {
		data() {
			return {
				list: [],
				path: baseURL + '/api/v1/common/download/'
			}
		},
		components: {
			'no-data': noData
		},
		onLoad() {
			let openid = wx.getStorageSync('openId')
			request({
				url: `/api/v1/people-info/openid?openid=${openid}`,
				method: 'GET'
			}).then(res => {
				let list = res.data;
				getGroupList('').then(res => {
					list.forEach(item => {
						item.groupName = getGroupName(res, item.groupId)
					})
					this.list = list;
				})

			})
		},
	}
</script>

<style>
	.item {
		width: 65%;
	}

	.group,
	.remark {
		width: 100%;
		font-size: 14px;
		word-wrap: break-word;
		overflow-wrap: break-word;
		margin: 2px 0;
	}

	.group {
		color: #908e8e;
	}

	.remark {
		color: red;
	}
</style>